home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 03 - 1987 / 03.09 Sep 87 / leach basic source / Listing 2.text < prev    next >
Encoding:
Text File  |  1987-07-19  |  2.7 KB  |  92 lines  |  [TEXT/EDIT]

  1.  
  2. REM This is listing 2 and is usable in MS BASIC 3.0 or greater
  3. REM create a macdraw PICT file
  4. REM Tech Note # 27 specifies the PICT file structure that is expected by MacDraw
  5.  
  6. LIBRARY "MSTools"
  7.  
  8.     DIM Grey%(3)
  9.     RESTORE PatternData
  10.     FOR j% = 0 TO 3 : READ Grey%(j%) : NEXT
  11.  
  12.     PatternData:
  13.         DATA -21931,-21931,-21931,-21931
  14.  
  15. REM define some objects that will be used for this demonstration
  16. REM read in the data that define the rectangle and circle
  17.  
  18. DIM rect%(3),aCircle%(3)
  19. RESTORE ObjectData
  20.   READ rect%(0)
  21.   READ rect%(1)
  22.   READ rect%(2)
  23.   READ rect%(3)
  24.   READ aCircle%(0)
  25.   READ aCircle%(1)
  26.   READ aCircle%(2)
  27.   READ aCircle%(3)
  28.  
  29.     ObjectData:
  30.       DATA 10,10,110,150,100,100,200,200
  31.       
  32.      X.Offset = 0        'offset to be used in saving the picture in MacDraw
  33.      Y.Offset = 0        ' if offsets are not zero the picture will have an upper     'right corner at that location
  34.   
  35.     REM record first picture with pen on so we can see it
  36.      PICTURE ON
  37.      CALL SHOWPEN
  38.          CALL PENSIZE(3,1)
  39.          CALL FRAMERECT(VARPTR(rect%(0)))
  40.          CALL PENNORMAL
  41.          
  42.          CALL PENPAT(VARPTR(Grey%(0)))
  43.          CALL PAINTOVAL(VARPTR(aCircle%(0)))
  44.  
  45.         CALL PENSIZE(3,3)
  46.          FOR indx% = 0 TO 3 : aCircle%(indx%) = aCircle%(indx%) + 50 : NEXT
  47.          
  48.          CALL FRAMEOVAL(VARPTR(aCircle%(0)))
  49.          CALL PENNORMAL
  50.          
  51.          CALL MOVETO  (10,10)
  52.          CALL LINETO (100,200)
  53.          
  54.     PICTURE OFF
  55.     pict1$ = PICTURE$
  56.     
  57.     REM now start the second picture as polygon
  58.     PGon! = 0
  59.     openPGon PGon!
  60.         CALL MOVETO(100,100)
  61.         FOR indx% = 1 TO 20
  62.             CALL LINE(indx%,10*SIN(indx%))
  63.         NEXT
  64.     CLOSEPGon
  65.     
  66.     PICTURE ON
  67.     FramePgon PGon!
  68.     PICTURE OFF
  69.     pict2$ = PICTURE$
  70.  
  71. REM we must group all of the separate pictures as a single picture
  72. REM before they can be outputted to the MacDraw™ PICT file
  73.     CALL HIDEPEN
  74.     PICTURE ON
  75.         PICTURE (X.Offset,Y.Offset), pict1$        'use any valid offset you wish
  76.         PICTURE (X.Offset,Y.Offset), pict2$         'use same offset to get                     'relationship right
  77.     PICTURE OFF
  78.     Pict$ = PICTURE$
  79.  
  80.     File.Pict$ = FILES$(0,"Name for this Picture ?")  'get the name of the file
  81.     IF LEN(File.Pict$) <  5 THEN END                        'if no file name then quit
  82.  
  83. OPEN File.Pict$ FOR OUTPUT AS #1
  84. FOR indx% = 1 TO 512      'print out the header for the PICT file
  85.       PRINT  #1,CHR$(0);     ' note use of ; to prevent chr$(13)
  86. NEXT 
  87. PRINT  #1,Pict$;                                 ' Print out the picture to the file
  88. CLOSE #1
  89. NAME File.Pict$ AS File.Pict$,"PICT"         'type the file as PICT so can open                 'from inside MacDraw™
  90. Setcreate File.Pict$ , "MDRW"
  91.  
  92.